package com.fengmi.controller;

import com.fengmi.dto.GoodDTO;
import com.fengmi.dto.PageDTO;
import com.fengmi.dto.ProductDTO;
import com.fengmi.entity.MallGoods;
import com.fengmi.service.IGoodsService;
import com.fengmi.vo.PageResultVO;
import com.fengmi.vo.ResultVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 作者：陈学虎
 * 时间：2021/7/11 0011 下午 7:26
 */
@RestController
@CrossOrigin
@RequestMapping("goods")
public class GoodsController {
    @Autowired
    private IGoodsService goodsService;

    @PostMapping("search")
    public PageResultVO<MallGoods> search(@RequestBody PageDTO<ProductDTO> pageDTO){
        return goodsService.findGoods(pageDTO);
    }

    @PostMapping("changeGoodStatus")
    @ApiOperation("修改商品的上下架状态")
    public ResultVO changeGoodStatus(@RequestBody MallGoods mallGoods){
        return goodsService.changeGoodStatus(mallGoods);
    }

    @PostMapping("savegoods")
    @ApiOperation("保存spu和sku信息")
    public ResultVO savegoods(@RequestBody GoodDTO goodDTO){
        return goodsService.save(goodDTO);
    }

}
